Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Use make-fetch-happen instead of request #3193

Merged
merged 4 commits into from
Dec 29, 2021

Conversation

CamilleDrapier
Copy link
Contributor

cf: #2851

Follows the implementation that was done here: #2961 ; also remove npmlog that seems unused from here on.

Because the latest node-gyp does not support python2 (https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#810-2021-05-28), use python3 for all nodes builds/tests. (Not sure if src/libsass/script/ci-report-coverage:8 should be affected?)

@nschonni
Copy link
Contributor

Thanks, but there is too much going on here. Dropping the rejectUnauthorized is being tracked in #3149 as a breaking change. Likewise, node-gyp/python2 dropping support will be when 12 goes EOL.
If you want to par it down to just changing the networking packing it could be considered.

@CamilleDrapier
Copy link
Contributor Author

Sorry for taking your time with this, I was merely trying to see if this would be reasonable enough.. while doing the changes locally it seemed okayish~~ but after creating the PR, I thought it might involve too many things that I did not understand enough.

Let's try to only replace the request/fetch, I missed seeing that the strictSSL/rejectUnauthorized option was supported by make-fetch-happen, but this rename probably impacts the PR you mentioned 🙇

@CamilleDrapier CamilleDrapier changed the title Update node-gyp, use make-fetch-happen Use make-fetch-happen instead of request Oct 14, 2021
@@ -21,21 +20,8 @@ var fs = require('fs'),

function download(url, dest, cb) {
var reportError = function(err) {
var timeoutMessge;

if (err.code === 'ETIMEDOUT') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does make-fetch-happen have a built-in way of handling timeouts?

Copy link
Contributor Author

@CamilleDrapier CamilleDrapier Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make-fetch-happen handles the timeout option that is passesed to node-fetch, that handles it according to this doc, which I assume should be similar to how request was handling that option.

Except that, for the timeout error handling, make-fetch-happen seems to have a built-in retry mechanism that could catch the ETIMEDOUT error (among others) and retry depending on the given configuration. Since we were not doing this here until now, I have not added it, but if this is something that could be useful from here, please let me know.

I'm unsure on how the timeout errors would be propagated and thus I thought this handler might become unused code, when testing timeouts (setting the timeout to 1, deleting the locale cached node-sass and running npm run install), I could produce the following error message which seems to be sufficient to me, but I might have missed the importance of having more specific messages (or handling more specific cases):

Downloading binary from https://github.com/sass/node-sass/releases/download/v6.0.1/linux-x64-93_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v6.0.1/linux-x64-93_binding.node": 

HTTP error ERR_SOCKET_TIMEOUT request to https://github.com/sass/node-sass/releases/download/v6.0.1/linux-x64-93_binding.node failed, reason: Socket timeout

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

@nschonni nschonni mentioned this pull request Oct 22, 2021
6 tasks
});
});

describe('with SASS_REJECT_UNAUTHORIZED set to false', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we restore this test I think we're ok to proceed.

@xzyfer
Copy link
Contributor

xzyfer commented Dec 28, 2021

I've rebase this on the latest master

@CamilleDrapier CamilleDrapier force-pushed the update-node-gyp-make-fetch branch from c603ac5 to 29ccc47 Compare December 28, 2021 07:49
@CamilleDrapier CamilleDrapier force-pushed the update-node-gyp-make-fetch branch from 29ccc47 to c7bb422 Compare December 28, 2021 07:49
Copy link
Contributor

@xzyfer xzyfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me. If @nschonni has no reservations I'm happy to roll give it a shot.

Copy link
Contributor

@nschonni nschonni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure will get some weird edge cases not matter what library we use, so I'm OK with giving this a try 😄

@xzyfer xzyfer merged commit 3bb51da into sass:master Dec 29, 2021
@xzyfer
Copy link
Contributor

xzyfer commented Dec 29, 2021

Thanks for your work @CamilleDrapier

thinhhuynh pushed a commit to OPSWAT/node-sass that referenced this pull request Feb 16, 2022
Fixes sass#3206

Co-authored-by: Camille Drapier <c.drapier@allm.inc>
Co-authored-by: Michael Mifsud <xzyfer@gmail.com>
tmarkley pushed a commit to tmarkley/OpenSearch-Dashboards that referenced this pull request Mar 24, 2022
* [CHANGELOG](https://github.com/ljharb/qs/blob/v6.10.3/CHANGELOG.md)
* The upstream library with a dependency on ~6.5.2 is `node-sass`, but
  that will not be addressed until sass/node-sass#3193
  is included in a release.

Resolves opensearch-project#1375

Signed-off-by: Tommy Markley <markleyt@amazon.com>
tmarkley pushed a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Mar 24, 2022
* [CHANGELOG](https://github.com/ljharb/qs/blob/v6.10.3/CHANGELOG.md)
* The upstream library with a dependency on ~6.5.2 is `node-sass`, but
  that will not be addressed until sass/node-sass#3193
  is included in a release.

Resolves #1375

Signed-off-by: Tommy Markley <markleyt@amazon.com>
@xzyfer
Copy link
Contributor

xzyfer commented Sep 8, 2022

This was accidentally released in v7.0.2 and subsequently broke binary downloads. See #3297

@CamilleDrapier
Copy link
Contributor Author

Sorry about this! Not really sure what is the underlying problem, but please let me know if I can help 🙇

@xzyfer
Copy link
Contributor

xzyfer commented Sep 8, 2022

No worries @CamilleDrapier, it was my mistake. My comment was intended for posterity. I've opened #3300 to track fixing it before releasing 8.0.0.

xzyfer added a commit that referenced this pull request Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants